package lm.spring.feign.support;

import feign.Client;
import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.codec.ErrorDecoder;
import feign.httpclient.ApacheHttpClient;
import org.springframework.context.annotation.Bean;

/**
* basePackages: @FeignClient所在的包
*/
@EnableFeignClients(basePackages = {"com.baidu"})
public class FeignClientsAutoConfiguration {

    @Bean(name = "feignErrorDecoder")
    public ErrorDecoder feignErrorDecoder() {
//        return new ApiErrorDecoder(); //json
        return new ErrorDecoder.Default();
    }

    @Bean(name = "feignDecoder")
    public Decoder feignDecoder() {
//        return new JacksonDecoder(); //json
        return new Decoder.Default();
    }

    @Bean(name = "feignEncoder")
    public Encoder feignEncoder() {
//        return new JacksonEncoder(); //json
        return new Encoder.Default();
    }

    @Bean(name = "feignClient")
    public Client feignClient() {
        return new ApacheHttpClient();
    }

}
